package ace.module.account.core.impl.listener;

import ace.module.account.core.impl.service.IamAccountInitService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * @author caspar
 * @date 2023/3/22 14:42
 */
@Order(1)
@Slf4j
@RequiredArgsConstructor
@Component
public class IamAccountInitListener implements ApplicationListener<ApplicationStartedEvent> {

  private final IamAccountInitService iamAccountInitService;

  @Override
  public void onApplicationEvent(ApplicationStartedEvent event) {
    this.init();
  }

  private void init() {
    this.iamAccountInitService.init();
  }
}
